$(function () {
    let url = 'http://localhost:8080/api/v1';

    $('.input_sub').on('click', function (event) {
        event.preventDefault();
        let username = $('.input_txt').val().trim();
        let password = $('.input_pass').val().trim();
        if (username == '' || password == '') {
            $('.modal-body p').html('请填写完整信息！！！');
            console.log();
            $('#myModal').modal();
            return;
        }
        $.ajax({
            type: 'post',
            url: url + '/admin/user/login',
            data: {
                username: username,
                password: password
            },
            success: function (backData) {
                $('.modal-body p').html(backData.msg);
                $('#myModal').modal();
                $('#myModal').on('hidden.bs.modal', function () {
                    if (backData.code == 200) {
                        window.localStorage.setItem('token', backData.token)
                        window.location.href = './index.html';
                    } else {
                        $('.input_txt').val('');
                        $('.input_pass').val('');
                    }
                })
            }
        })


    })


})